﻿using Bridge.Shared.Models;
using Microsoft.AspNetCore.Mvc;
using Orders;
using Orders.Input;
using Orders.Output;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.AspNetCore.Mvc;

namespace Bridge.Wms.HttpApi
{
    [Route("[controller]/[action]")]
    public class OrderController : AbpController
    {
        private IOrderService _orderService { get; set; }
        public OrderController(IOrderService orderService) {
        _orderService = orderService;
        
        }
        [HttpPost]
        public async Task<PageResponseResult<OrderOutput>> GetOrderList([FromBody] OrderInput input)
        {
            try
            {
              return  await _orderService.GetOrderList(input);
            }
            catch (Exception e)
            {

                return PageResponseResult<OrderOutput>.Fail("获取订单出错！");
            }
        }

        [HttpPost]
        public async Task<ResponseResult> CreateOrUpdateOrder([FromBody] CreateOrUpdateOrderInput input)
        {
            try
            {
                return await _orderService.CreateOrUpdateOrder(input);
            }
            catch (Exception e)
            {

                return PageResponseResult<OrderOutput>.Fail("保存订单出错！");
            }
        }
    }
}
